package com.dropesoft.ui;



import com.dropesoft.biz.TypesDbAdapter;

import android.app.Activity;
import android.content.res.Resources;
import android.database.Cursor;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

public class LayoutUtility extends Activity {

	public  LayoutUtility() {}
	
	public void getAllTypes(Spinner spObject)
	{
		String[] arrTypes = new String[3];
		TypesDbAdapter dbTypes = new TypesDbAdapter(this);
		Cursor cursor = null;
		
		try		
		{
			cursor = dbTypes.listAllTypes();
			
		}
		catch (Exception e)
		{
		 
		}
		
		
		
		Resources res = getResources();
		String internalName = null;
		
		int i = 0;
		while(cursor.moveToNext())
		{
			internalName = cursor.getString(1);
			arrTypes[i] = res.getResourceName(res.getIdentifier(internalName, "values/types", getPackageName()));
			i++;
		}
		
		ArrayAdapter<String> arrAdapter = new ArrayAdapter<String>(this, spObject.getId(), arrTypes);
		arrAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); // The drop down vieww
		spObject.setAdapter(arrAdapter);
		
	}
	
}
